package com.cy.api;

import com.cy.annotation.IgnoreAuth;
import com.cy.annotation.LoginUser;
import com.cy.entity.User;
import com.cy.service.UserService;
import com.cy.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * API测试接口
 *
 * @author chenyi
 * @email 228112142@qq.com
 * @date 2017-08-25 08:47
 */
@RestController
@RequestMapping("/api")
public class ApiTestController {
    @Autowired
    private UserService userService;
    /**
     * 获取用户信息
     */
    @GetMapping("userInfo")
    public R userInfo(@LoginUser User user){
        return R.ok().put("user", user);
    }

    /**
     * 忽略Token验证测试
     */
    @IgnoreAuth
    @GetMapping("notToken")
    public R notToken(){
        return R.ok().put("msg", "无需token也能访问。。。");
    }



    @PostMapping("list")
    public R list(){

       User user= userService.queryObject((long)1);

        return R.ok().put("user", user);
    }
}
